%% Part of Computer Shop Demo
%% 
-include_lib("ect/include/ect.hrl").

-module(device_main).
-export([main/0, dotest/0]).

-import_class(device).
-import_class(monitor).
-import_class(printer).


-record(proba, {a, b}).

main() ->
    A = #monitor{serial = 1, price = 500, age = 3},
    B = #printer{serial = 2, price = 200, toner_price = 2000},
    
    %% method calls:    
    {A}:print(),
    {B}:print(),
    A2 = {A}:sell("Bela"),
    B2 = {B}:sell("Jani"),
    {A2}:print(),
    {B2}:print().
    
dotest() ->
    A = #monitor{serial = 1, price = 500, age = 3},
    B = #printer{serial = 2, price = 200, toner_price = 2000},
    
%%    {A}:print(),
%%    {B}:print(),
    A2 = {A}:sell("Bela"),
    B2 = {B}:sell("Jani"),
%%    {A2}:print(),
%%    {B2}:print(),
    X = #proba{},
    if ( A2#monitor.customer =:= "Bela" andalso B2#device.customer =:= "Jani") ->
	    pass;
       true ->
	    fail;
       ( not (A2#monitor.customer =:= 2) andalso 1 =:= 1) ->
            hehe;
       A2#monitor.customer =:= 2 ->
            haha
    end.
